package edu.ihs.lhpy.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import edu.ihs.lhpy.base.BaseDaoImpl;
import edu.ihs.lhpy.cfg.Configuration;
import edu.ihs.lhpy.domain.PageBean;
import edu.ihs.lhpy.domain.StudentsGuide;
import edu.ihs.lhpy.service.StudentsGuideService;

@Service
public class StudentsGuideServiceImpl extends BaseDaoImpl<StudentsGuide> implements StudentsGuideService{

	@Override
	public PageBean getPageBean(int pageNum) {
		int pageSize = Configuration.getPageSize();
		//查询本页的数据列表
		List recordList = getSession().createQuery(//
				"FROM StudentsGuide n ORDER BY n.time ASC")//
				.setFirstResult((pageNum - 1) * pageSize)
				.setMaxResults(pageSize)
				.list();
		//查询总列表数
		Long count = (Long)getSession().createQuery(//
				" SELECT COUNT(*) FROM StudentsGuide ")//
				.uniqueResult();
		
		return new PageBean(recordList, pageSize, pageNum, count.intValue());
	}

}
